<template>
  <div class="app-container">
   
    <div class="filter-container">
      <el-input @keyup.enter.native="handleFilter" style="width: 200px;" class="filter-item" placeholder="请输入任务名称" v-model="listQuery.name"></el-input>
      <!-- <el-button class="filter-item" type="primary" style="float:right;"  icon="el-icon-edit"  @click="handleCreate">部署</el-button> -->
      <el-button class="filter-item" type="primary" style="float:right;margin-right:10px;" v-waves icon="el-icon-search" @click="handleFilter">查询</el-button>
    </div>
    <el-table :key='tableKey' :data="list" v-loading="listLoading" element-loading-text="给我一点时间" border fit highlight-current-row
      style="width: 100%">
      <el-table-column align="center" label="行号" width="65">
        <template slot-scope="scope">
          <span>{{scope.$index+1}}</span>
        </template>
      </el-table-column>
      <el-table-column width="350px" align="center" label="ID">
        <template slot-scope="scope">
          <span>{{scope.row.id }}</span>
        </template>
      </el-table-column>
      <el-table-column width="150px" align="center" label="name">
        <template slot-scope="scope">
          <span>{{scope.row.name }}</span>
        </template>
      </el-table-column>
      <el-table-column min-width="150px" label="assignee">
        <template slot-scope="scope">
          <span class="link-type" >{{scope.row.assignee }}</span>
        </template>
      </el-table-column>
      <el-table-column width="110px" align="center" label="owner">
        <template slot-scope="scope">
          <span>{{scope.row.owner}}</span>
        </template>
      </el-table-column>
      <el-table-column width="110px" align="center" label="priority">
        <template slot-scope="scope">
          <span>{{scope.row.priority}}</span>
        </template>
      </el-table-column>
      <el-table-column width="110px" align="center" label="createTime">
        <template slot-scope="scope">
          <span>{{scope.row.createTime}}</span>
        </template>
      </el-table-column>
      <el-table-column width="110px" align="center" label="dueDate">
        <template slot-scope="scope">
          <span>{{scope.row.dueDate}}</span>
        </template>
      </el-table-column>
    
    </el-table>

    <!-- <div class="pagination-container">
      <el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="listQuery.page" :page-sizes="[10,20,30, 50]" :page-size="listQuery.limit" layout="total, sizes, prev, pager, next, jumper" :total="total">
      </el-pagination>
    </div> -->
     <el-dialog title="Reading statistics" :visible.sync="dialogPvVisible">
      <el-table :data="pvData" border fit highlight-current-row style="width: 100%">
        <img src=""/>
      </el-table>
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="dialogPvVisible = false">confirm</el-button>
      </span>
    </el-dialog>

    

  </div>
</template>

<script>
import { getTasks  } from '@/api/flow.js'
import waves from '@/directive/waves' // 水波纹指令
import { parseTime, formatDate  } from '@/utils'
export default {
  name: 'flowable',
  directives: {
    waves
  },
  data() {
    return {
      tableKey: 0,
      list: null,
      total: null,
      listLoading: true,
      listQuery: {
        name: '',
        page: 1,
        limit: 20,
        importance: undefined,
        title: undefined,
        type: undefined,
        sort: '+id'
      },
      temp: {
        id:undefined,
	      name: undefined,
	      assignee: undefined,
	      owner: undefined,
	      priority: undefined,
	      createTime: undefined,
	      dueDate: undefined
      },
      dialogFormVisible: false,
      dialogStatus: '',
      textMap: {
        update: 'Edit',
        create: 'Create'
      },
      dialogPvVisible: false,
      dialogDetailVisible:false,
      pvData: [],
      rules: {
        appName: [{ required: true, message: 'appName is required', trigger: 'change' }],
        remark: [{ required: true, message: 'remark is required', trigger: 'change' }]
      }
    }
  },
  filters: {
    formatDate(time) {
       //var date = new Date(time);
      return formatDate(time, 'yyyy-MM-dd hh:mm');
    }   
  },
  created() {
    this.getList()
  },
  methods: {
    getList() {
      this.listLoading = true
      const param = {
        'body': {
          "taskDTO":{
            "name":this.listQuery.name
          }
        }
      }
      getTasks(param).then(response => {
        this.list = response.body.taskDTOList
        this.listLoading = false
      })
    },
    handleFilter() {
      this.listQuery.page = 1
      this.getList()
    },
    handleSizeChange(val) {
      this.listQuery.limit = val
      this.getList()
    },
    handleCurrentChange(val) {
      this.listQuery.page = val
      this.getList()
    },
    
    handleCreate() {
      this.resetTemp()
      this.dialogStatus = 'create'
      this.dialogFormVisible = true
      this.$nextTick(() => {
        this.$refs['dataForm'].clearValidate()
      })
    }
   
  }
}
</script>
